package engine.logic
{
	import engine.data.ModelLocator;
	import engine.data.RoleVo;
	import engine.data.Scene;
	import engine.data.View;
	import engine.data.ViewObject;
	import engine.event.SceneEvent;
	import engine.flag.GameDefine;
	import engine.newUi.CheckModifiedEnableLogic;
	import engine.newUi.KungfuPackLogic;
	import engine.newUi.PartnerRequestLogic;
	import engine.newUi.PartnerRequestNewLogic;
	import engine.newUi.PulseLogic;
	import engine.newUi.SkillLogic;
	import engine.newUi.StatusShopUI;
	
	import newx.com.config.StaticIni;

	/**
	 *	死亡帮助logic 
	 * @author lw
	 * 
	 */
	public class DieHelpLogic
	{
		//强化, 阵法, 武学,丹药,经脉,伙伴 武学获取,布阵,礼包
		/**
		 *	装备升级 
		 */
		public static const EQUIP : int = 1;
		
		/**
		 *	 阵法升级
		 */
		public static const SKILL : int = 2;
		
		
		/**
		 *	武学装备 
		 */
		public static const KUNGFU_EQUIP: int = 3;
		
		
		/**
		 *	经脉升级 
		 */
		public static const PULSE : int = 5;
		
		
		/**
		 *	伙伴邀请 
		 */
		public static const BUDDY : int = 6;
	
		/**
		 *	武学获取 
		 */
		public static const KUNGFU_GET: int = 7;
		
		/**
		 *布阵 
		 */
		public static const EMBATTLE	: int = 8;
		
		/**
		 *	礼包使用
		 */
		public static const GIFT 	: int = 9;
	
		
		
		
		
		
		private var _model	: ModelLocator;
		
		private var _scene	: Scene;
		
		private var _role	: RoleVo;
		
		public static var _self:DieHelpLogic;
		
		public function DieHelpLogic()
		{
			_model = ModelLocator.getInstance();
		
			_scene = _model.scene;
			
			_role = _scene.Role;
			
//			_model.addEventListener( SceneEvent.SceneLoaded, onSceneLoaded );
		}
		
		public static function getInstance():DieHelpLogic
		{
			if(_self == null)
			{
				_self =new DieHelpLogic();
			}
			return _self;
		}
		
		private function onSceneLoaded( evt : SceneEvent ):void
		{
//			_model.removeEventListener( SceneEvent.SceneLoaded, onSceneLoaded );
			
			giftHelp();
		}
		
		/**
		 *	是否使用礼品提示 
		 * @return 
		 * 
		 */
		public function giftHelp():Boolean
		{
			//获取背包
			var packView : View = _model.scene.GetView( View.VIEWPORT_TOOL );
			var canUse : Boolean = false;
			//遍历背包，判断是否有礼包
			packView.getDataForEach( canUseGift );
			
		
			//是否有可以使用的礼包
			var item : ViewObject;
			function canUseGift( propName:String,val:* ):void
			{
				item = val as ViewObject;
				if( null != item  )
				{
					if( item.GetPropertiesEx( "ItemType" ) == GameDefine.ItemType_GOLDBOX 
						&& item.GetPropertiesEx( "SubItemType" ) == GameDefine.SubItemType_box)
					{//是礼包
						if( int( StaticIni.getIniVar( item.GetPropertiesEx( "ConfigID" ), "NeedLevel" ) ) <= _role.getPlayerLevel() )
						{//玩家达到了使用等级
							canUse = true;
							return;
						}
					}
				}
			}
			
			if( canUse )
			{
				return true;
			}
			
			return false;
		}
		
		/**
		 *	是否使用经脉提示 ,先过一下
		 * @return 
		 * 
		 */
		public function puliseHelp():Boolean
		{
			return  PulseLogic.getInstance().checkIsCanStudy();
		}
		
		/**
		 *	是否使用功夫提示 
		 * @return 
		 * 
		 */		
		public function kungfuHelp():Boolean
		{
			var type : int = KungfuPackLogic.getInstance().checkGuide;
			
			if( -1 != type )
			{
				return true;
			}
			
			return false;
		}
		
		/**
		 *	是否使用强化 
		 * @return 
		 * 
		 */		
		public function equipHelp():Boolean
		{
			var type:int	=	CheckModifiedEnableLogic.getInstance().checkGuide;
			if( -1 != type )
			{
				return true;
			}
			return false;
		}
		
		/**
		 *	是否使用伙伴邀请 
		 * @return 
		 * 
		 */		
		public function buddyHelp():Boolean
		{
			var type : int = PartnerRequestNewLogic.getInstance().checkGuide;
			
			if( -1 != type )
			{
				return true;
			}
			
			return false;
		}
		
		/**
		 *	是否使用阵法升级 
		 * @return 
		 * 
		 */		
		public function skillHelp():Boolean
		{
			var type:int = StatusShopUI.getInstance().checkGuide;
			
			if( -1 != type )
			{
				return true;
			}
			return false;
		}
	}
}